import {myRequest} from '@/util/api.js'
import common from '@/util/util'
// 显示资产的接口方法
  // basicUrl:基准路由
  // type：什么提交类型
  // resource：传入的资源
  // params：正常的参数
  // 后拼接的路由
export function loginAPI(params, type, resource, secondUrl) {
  const basicUrl = '/wx/auth/loginByWeixin'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
    data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}
// 获取后台
export function getTel(params, type, resource, secondUrl) {
  const basicUrl = '/wx/wechat/wxGetPhoneNumber'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 获取后台
export function getQrCodeImgUrl(params, type, resource, secondUrl) {
  const basicUrl = '/wx/wechat/getQrCodeImgUrl'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 获取用户兑换次数
export function userGiftCount(params, type, resource, secondUrl) {
  const basicUrl = '/wx/biz/userGiftCount'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

//签名
export function prepay(params, type, resource, secondUrl) {
  const basicUrl = '/wx/biz/prepay'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
    data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 推广
export function addPublicize(params, type, resource, secondUrl) {
  const basicUrl = '/wx/biz/addPublicize'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}


// 验证是否第一次下单
export function ifFirstOrder(params, type, resource, secondUrl) {
  const basicUrl = '/wx/coupon/ifFirstOrder'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 验证用户是否第一次登录
export function ifFirstLogin(params, type, resource, secondUrl) {
  const basicUrl = '/wx/coupon/ifFirstLogin'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 添加优惠券
export function createCoupon(params, type, resource, secondUrl) {
  const basicUrl = '/wx/coupon/createCoupon'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}

// 查询我的优惠券
export function findUserCoupon(params, type, resource, secondUrl) {
  const basicUrl = '/wx/coupon/findUserCoupon'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}


//获取抽奖次数
export function userDrowsNum(params, type, resource, secondUrl) {
  const basicUrl = '/wx/coupon/userDrowsNum'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}


//赠品兑换
export function redeemGifts(params, type, resource, secondUrl) {
  const basicUrl = '/wx/biz/redeemGifts'
  return myRequest({
    url: common.getUrl(basicUrl, resource, secondUrl),
    method: type,
     data: ['put', 'post','get', 'delete'].indexOf(type) >= 0 ? params : null,
  })
}





